﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>会员充值</title>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .allContent{ width:600px; margin:0px auto;}
        .fieldCss{ border: solid 1px #C6E2FF;width: 550px;padding: 10px 10px 10px 10px;}
        input[ type="text"]{width:150px;border:none; border-bottom:solid 1px #ccc; height:18px; line-height:18px; font-size:12px;  padding:1px 2px 1px 2px;}
    </style>

</head>
<body class="main">
    <div class="AllWebTopDiv">
        <div class="path">
            <div class="nav">
                <a href="#">会员充值</a>
            </div>
         </div>
         <div class="content">
          <div class="allContent">
          
           <fieldset class="fieldCss">
                        <legend>会员信息</legend>
                        <form>
                        <label>
                            会员卡号：</label><%:Html.TextBox("memberId", null, new { @readonly = "readonly" })%>  
                        <label>
                            卡内余额：</label><%:Html.TextBox("balance", null, new { @readonly="readonly"})%><br />
                            
                        <br />
                        <label>
                            会员姓名：</label><%:Html.TextBox("memberName", null, new { @readonly = "readonly" })%>
                        <label>
                            现有积分：</label><%:Html.TextBox("point", null, new { @readonly = "readonly" })%>
                            </form>
               </fieldset>
               <br /><br />
               <fieldset class="fieldCss">
                        <legend>充值金额</legend>
                         <label>充值金额：</label>
                         <%:Html.TextBox("money", null, new { onpropertychange = "ChangeRecharge()" })%>
               </fieldset>
               <br /><br />
                <fieldset class="fieldCss">
                        <legend>结算</legend>
                         <label>赠送金额：</label>
                         <%:Html.TextBox("sendMoney", null, new { onpropertychange = "ChangeRecharge()" })%> 
                         <label>充值总额：</label>
                         <%:Html.TextBox("afterMoney", null, new { @readonly = "readonly" })%>
               </fieldset>
                <br /><br />
                <fieldset class="fieldCss">
                        <legend>票据打印</legend>
                        <input  type="checkbox"/>
                         <label>票据打印：</label>
                         <label>附加信息：</label>
                         <%:Html.TextBox("msg") %>
               </fieldset>
                  <br /><br />
                <div>
                  <input  type="button" value="充值" class="button2" onclick="Recharge()"  style="margin-left:100px;"/>
                  <input  type="button" value="退出" class="button2" onclick="closeWindows()" style="margin-left:100px;"/>
                </div>
           </div>
         </div>
    </div>
</body>
</html>
<script type="text/javascript">

      //改变充值后的金额
    function  ChangeRecharge() {
        var re = /^[0-9]*[1-9][0-9]*$/;
        var rex = /([1-9]\d*\.?\d*)|(0\.\d*[1-9])/;
        if (re.test($("#money").val())) {
            if (rex.test($("#sendMoney").val())) {
                $("#afterMoney").val(parseFloat($("#money").val()) + parseFloat($("#sendMoney").val()));
            }
            else {
                $("#afterMoney").val($("#money").val());
            }
        }
        else {
            alert("请输入正确金额");
        }


    }
    // 充值
    function Recharge() {
        var rex = /([1-9]\d*\.?\d*)|(0\.\d*[1-9])/;
        if (rex.test($("#afterMoney").val())) {
            var afterMoney = $("#afterMoney").val();
            var memberId = $("#memberId").val();
            $.ajax({
                type: 'post',
                url: '<%:Url.Action("RechargeMoney","Recharge") %>',
                data: "afterMoney=" + afterMoney + "&memberId=" + memberId + "",
                cache: false,
                success: function (txt) {
                    eval(txt);
                }

            });
        }
        else {
            alert("充值后金额有误");
        }
    
    }
    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return (r[2]); return null;
    }
    //关闭窗口
    function closeWindows() {
        var test = GetQueryString("memberId");
        var test2 = GetQueryString("back");
        if (test == null || test == "") { 
                window.location.href = "/Loading/Index/?src=/Desktop/Index/"; 
     }
     else {
         var i = parent.layer.getFrameIndex();
         parent.layer.close(i);
     }
    }
</script>